import request from "@/utils/request";

/**
 * 获取用户包材设置
 * @returns {Promise | Promise<unknown>}
 */
export function getUserPackageMaterialSetting() {
  return request({
    url: "/packetGoods/getUserPackageMaterialSetting",
    method: "get"
  })
}

/**
 * 保存用户包材设置
 * @param goodsData
 * @returns {Promise | Promise<unknown>}
 */
export function savePacketGoodsData(goodsData) {
  return request({
    url: "/packetGoods/savePacketGoodsData",
    method: "post",
    data: goodsData
  })
}

/**
 * 更新用户包材设置
 * @param packetGoodsId
 * @param goodsData
 * @returns {Promise | Promise<unknown>}
 */
export function updatePacketGoodsData(packetGoodsId, goodsData) {
  return request({
    url: "/packetGoods/updatePacketGoodsData/" + packetGoodsId,
    method: "patch",
    data: goodsData
  })
}

/**
 * 获取用户包材设置
 * @param packetGoodsId
 * @returns {Promise | Promise<unknown>}
 */
export function getPacketGoodsInfo(packetGoodsId) {
  return request({
    url: "/packetGoods/getPacketGoodsInfo/" + packetGoodsId,
    method: "get"
  })
}

/**
 * 获取模板数据(小包商品)
 * @returns {Promise<unknown>}
 */
export function getBatchUploadPacketGoodsTemplate(){
  return request({
    url: '/packetGoods/getBatchUploadPacketGoodsTemplate',
    method: "get",
    responseType: "blob", // 需要加上
    isNotJson: true,
    timeout: 60000 * 5, // 1分钟
    handleError: true,
  })
}

/**
 * 查询批量上传列表(商品)
 * @param paramsData
 * @returns {Promise | Promise<unknown>}
 */
export function getBatchUploadPacketGoodsList(paramsData) {
  return request({
    url: "/packetGoods/getBatchUploadPacketGoodsList",
    method: "get",
    data: paramsData
  })
}

/**
 * 查询批量上传的错误信息(商品)
 * @param id
 * @param paramsData
 * @returns {Promise | Promise<unknown>}
 */
export function getBatchUploadPacketGoodsErrorData(paramsData, id) {
  return request({
    url: "/packetGoods/getBatchUploadPacketGoodsErrorData/" + id,
    method: "get",
    data: paramsData
  })
}
